<?php

    session_start();

    if (!isset($_SESSION['logged'])) {
        @header("Location: login.php");
        die;
    }

    if (!file_exists("../config.php")) {
        @header("Location: ../install.php");
        die;
    }

    include("../global_conf.php");
    require_once("./admin_lib.php");

    include($site->langdir."/languages.php");
    // Per la lingua
    if (isset($_POST['change_lang'])) {
        $_SESSION['lang'] = array_search($_POST['language'], $languages);
        DBmanager::getInstance()->change_user_lang($_SESSION['logged'], $_SESSION['lang']);
    }

    require_once($site->langdir."/".$_SESSION['lang'].".lang.php");

    $hometab="class=\"active\"";
    include("./include/admin_header.php");
?>
    <div id="page">
    <div id="page-bgtop">
    <div id="page-bgbtm">
        <div id="content">
            <div class="post"><h2 class="title"><?php echo $_LANG['admin home page']; ?></h2>
    <?php
        echo "<h3 class=\"title\">".$_LANG['last inserted contents']."</h3>";
        $cont=get_last_contents_inserted();
    ?>
            <div style="clear: both">&nbsp;</div>
    <?php
        if (count($cont) < 1) {
            echo $_LANG['no last inserted contents'];
        }
        else {
            foreach ($cont as $key => $value) {
                echo "<div class=\"entry\">".$key." => ".$value."</div>";
            }
        }

        if (strcmp($_SESSION['role'], "insert") != 0) {
            echo "<h3 class=\"title\">".$_LANG['contents to be published']."</h3>";
            $cont=get_last_contents_inserted(0);
            if (count($cont) < 1) {
                echo $_LANG['no contents to be published'];
            }
            else {
                foreach ($cont as $key => $value) {
                    echo "<div class=\"entry\">".$key." => ".$value."</div>";
                }
            }
        }
    ?>
            </div>
        </div>
        </div>
        <div style="clear: both">&nbsp;</div>
    </div>
    </div>
<?php
    include("./include/admin_footer.php");
?>